//
//  WYCSeeBillController.m
//  初试
//
//  Created by 中企互联 on 2017/10/16.
//  Copyright © 2017年 李胜军. All rights reserved.
//首页点击cell

#import "WYCSeeBillController.h"
#import "WYCTranslationController.h"
#import "WYCHistoryController.h"
#import "WYCPlanController.h"
#import "WYCSeeBillModel.h"
#import "WYCIntelligentMoneyController.h"
#import "PopViewController.h"
#import "OYRPopOption.h"
#import "WYCHandBillController.h"
#import "WYCBillController.h"
#import "consumptionViewController.h"
#import "UIViewController+HUD.h"
@interface WYCSeeBillController ()<UIScrollViewDelegate>
{
    NSString * codeStr;
}

/** 遮盖View*/
@property(nonatomic,strong)UIView * coverView;

/** view*/
@property(nonatomic,strong)UIView * backView;
@property(nonatomic,strong)    UILabel * typelabel;

/** 标签栏底部的红色指示器 */
@property (nonatomic, weak) UIView  * indicatorView;
/** 底部所有的标签 */
@property (nonatomic, weak) UIView  * titlesView;


/** 数组*/
@property (nonatomic, weak) NSArray  * titlesArray;


/** 模型赋值*/
@property(nonatomic,strong)WYCSeeBillModel * seeBillModel;

/** 底部所有的内容 */
@property (nonatomic, weak) UIScrollView  * contenView;

/** 取反 */
@property (nonatomic, weak) UIButton  * selectedButton;

/** 取输入框 */
@property (nonatomic, weak)UITextField * texField;


@end

@implementation WYCSeeBillController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self setupbottomView];

    //Nav
  
   // [self loadversion];
   
}
- (void)setupVersion{
    
    NSDictionary *infoDic = [[NSBundle mainBundle] infoDictionary];
    
    // 获取App的版本号
    NSString *appVersion = [infoDic objectForKey:@"CFBundleShortVersionString"];
    WYCLog(@"=======%@",appVersion);
//    
//    NSString * iosVersion = [NSString stringWithFormat:@"%@%@",iosfunction,appVersion];
//    [HttpTool POST:iosVersion params:nil success:^(NSURLSessionDataTask *task, id responseObject) {
//        WYCLog(@"--------%@",responseObject);
//        if ([[responseObject objectForKey:@"code"] intValue] == 0) {
//            codeStr = [responseObject objectForKey:@"result"];
//        }
//    } fail:^(NSURLSessionDataTask *task, NSError *error) {
//        
//    }];
}

#pragma make -------->>请求数据
- (void)setupRequster{
    NSMutableDictionary * params = [NSMutableDictionary dictionary];
    params[@"cardId"] = self.cardId;
    params[@"token"] = [WYCAccountTool unarchivetoken];
    
    [HttpTool POST:creditcarddetails params:params success:^(NSURLSessionDataTask *task, id responseObject) {
        if ([[responseObject objectForKey:@"code"] intValue] == 0) {
            NSDictionary * dict = responseObject[@"result"];
            self.seeBillModel = [WYCSeeBillModel mj_objectWithKeyValues:dict];
        }else{
            
            [SVProgressHUD showImage:[UIImage imageNamed:@""] status:msgStr];
            [SVProgressHUD setDefaultStyle:SVProgressHUDStyleCustom];
            [SVProgressHUD setForegroundColor:[UIColor whiteColor]]; //字体颜色
            [SVProgressHUD setBackgroundColor:[UIColor blackColor]];   //背景颜色
        }
        //界面
        [self setupCreat];
    } fail:^(NSURLSessionDataTask *task, NSError *error) {
        
    }];
    
}
//底部还款
- (void)setupbottomView{
    //底部view
    UIView * bottomView = [[UIView alloc] init];
    bottomView.frame = CGRectMake(0, ScreenHeight - 160 * px, ScreenWidth, 160 * px);
    bottomView.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:bottomView];
    
    //标记已还金额
    UIButton * alreadylabel = [[UIButton alloc] init];
    alreadylabel.frame = CGRectMake(0, 0, bottomView.width / 2, 160 * px);
    alreadylabel.contentVerticalAlignment = UIControlContentHorizontalAlignmentCenter;
    [alreadylabel setTitle:@"快速消费" forState:UIControlStateNormal];
    [alreadylabel setTitleColor:wycMain forState:UIControlStateNormal];
    [alreadylabel addTarget:self action:@selector(alreadylabelClick) forControlEvents:UIControlEventTouchUpInside];
    alreadylabel.titleLabel.font = [UIFont systemFontOfSize:BigFont];
    [bottomView addSubview:alreadylabel];
    
    
    //标记已还清
    UIButton * payofflabel = [[UIButton alloc] init];
    payofflabel.frame = CGRectMake(bottomView.width / 2, alreadylabel.y, alreadylabel.width, alreadylabel.height);
    payofflabel.contentVerticalAlignment = UIControlContentHorizontalAlignmentCenter;
    [payofflabel setTitle:@"智能还款" forState:UIControlStateNormal];
    payofflabel.backgroundColor = wycMain;
    [payofflabel addTarget:self action:@selector(payofflabelClick) forControlEvents:UIControlEventTouchUpInside];
    [payofflabel setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    payofflabel.titleLabel.font = [UIFont systemFontOfSize:BigFont];
    [bottomView addSubview:payofflabel];
}
/**
 *底部的scrollview
 */
- (void)setupScrollView
{
    //不自动调整inset
    self.automaticallyAdjustsScrollViewInsets = NO;
    UIScrollView * contenView = [[UIScrollView alloc]init];
    contenView.frame = self.view.bounds;
    contenView.delegate = self;
    contenView.pagingEnabled = YES;
    
    [self.view insertSubview:contenView atIndex:0];
    contenView.contentSize = CGSizeMake(contenView.width * self.childViewControllers.count,0 );
    
    self.contenView = contenView;
    //
    //    //添加第一个控制器view
    [self scrollViewDidEndScrollingAnimation:contenView];
}


//初始化子控制器
- (void)setupChildVces{
    WYCTranslationController * Translation = [[WYCTranslationController alloc] init];
    Translation.cardId = self.cardId;
    Translation.title = @"账单明细";
    
    [self addChildViewController:Translation];
    
    WYCHistoryController * History = [[WYCHistoryController alloc] init];
    History.cardId = self.cardId;
    History.title = @"还款记录";
    
    [self addChildViewController:History];
    
    WYCPlanController * Plan = [[WYCPlanController alloc] init];
    Plan.title = @"智能还款计划";
    Plan.cardId = self.cardId;
    [self addChildViewController:Plan];
    
}
//界面
- (void)setupCreat{
    //蓝色
    UIImageView * backView = [[UIImageView alloc] init];
    backView.frame = CGRectMake(0, NavHeight, ScreenWidth, 200);
    backView.backgroundColor = wycMain;
    [self.view addSubview:backView];
    
    
    //白色
    UIImageView * backView2 = [[UIImageView alloc] init];
    backView2.frame = CGRectMake(10, 20, ScreenWidth-20, 170);
    backView2.layer.cornerRadius = 30 * px;
    [backView addSubview:backView2];
    UIImageView * bankImage = [[UIImageView alloc] init];
    bankImage.frame = CGRectMake(20, 20, 25, 25);
//    bankImage.layer.cornerRadius = 30 * px;
    [backView2 addSubview:bankImage];
    
    NSInteger bankid = [self.bankid integerValue];
    
    switch (bankid) {
        case 10000://招商银行
            backView2.image = [UIImage imageNamed:@"bank_bg_zhaoshang"];
            bankImage.image = [UIImage imageNamed:@"bank_icon_zs"];
            break;
        case 10001://工商银行
           backView2 .image = [UIImage imageNamed:@"bank_bg_gongshang"];
            bankImage.image = [UIImage imageNamed:@"bank_icon_gs"];
            
            break;
        case 10002://农业银行
            backView2.image = [UIImage imageNamed:@"bank_bg_ny"];
            bankImage.image = [UIImage imageNamed:@"bank_icon_ny"];
            
            break;
        case 10003://  建设银行
            backView2.image = [UIImage imageNamed:@"bank_bg_jianshe"];
            bankImage.image = [UIImage imageNamed:@"bank_icon_js"];
            
            break;
        case 10004://中国银行
            backView2.image = [UIImage imageNamed:@"bank_bg_zhongguo"];
            bankImage.image = [UIImage imageNamed:@"bank_icon_zy"];
            
            break;
        case 10005:  //浦发银行
            backView2.image = [UIImage imageNamed:@"bank_bg_pufa"];
            bankImage.image = [UIImage imageNamed:@"bank_icon_pf"];
            
            break;
        case 10006:  //交通银行
            backView2.image = [UIImage imageNamed:@"bank_bg_jiaotong"];
            bankImage.image = [UIImage imageNamed:@"bank_icon_jt"];
            
            break;
        case 10007:  //民生银行
            backView2.image = [UIImage imageNamed:@"bank_bg_minsheng"];
            bankImage.image = [UIImage imageNamed:@"bank_icon_ms"];
            
            break;
        case 10009:  //广东发展银行
            backView2.image = [UIImage imageNamed:@"bank_bg_gf"];
            bankImage.image = [UIImage imageNamed:@"bank_icon_gf"];
            
            break;
        case 10010:  //中信银行
            backView2.image = [UIImage imageNamed:@"bank_bg_zhongxin"];
            bankImage.image = [UIImage imageNamed:@"bank_icon_zx"];
            
            break;
        case 10011:  //  华夏银行
            backView2.image = [UIImage imageNamed:@"bank_bg_hx"];
            bankImage.image = [UIImage imageNamed:@"bank_icon_hx"];
            
            break;
        case 10012:  //  兴业银行
            backView2.image = [UIImage imageNamed:@"bank_bg_xingye"];
            bankImage.image = [UIImage imageNamed:@"bank_icon_xy"];
            
            break;
        case 10014:  //  江苏银行
            backView2.image = [UIImage imageNamed:@"bank_bg_jiangsu"];
            bankImage.image = [UIImage imageNamed:@"bank_icon_gs"];
            
            break;
        case 10016:  //  北京银行
            backView2.image = [UIImage imageNamed:@"bank_bg_bj"];
            bankImage.image = [UIImage imageNamed:@"bank_icon_bj"];
            
            break;
        case 10020://10020  光大银行
            backView2.image = [UIImage imageNamed:@"bank_bg_gd"];
            bankImage.image = [UIImage imageNamed:@"bank_icon_gd"];
            
            break;
        case  10024://平安银行
            backView2.image = [UIImage imageNamed:@"bank_bg_pinan"];
            bankImage.image = [UIImage imageNamed:@"bank_icon_pa"];
            
            break;
        case 10027:  //上海银行
            backView2.image = [UIImage imageNamed:@"bank_bg_shanghai"];
            bankImage.image = [UIImage imageNamed:@"bank_icon_sh"];
            
            break;
        case  10028://  中国邮政储蓄银行
            backView2.image = [UIImage imageNamed:@"bank_bg_youzheng"];
            bankImage.image = [UIImage imageNamed:@"bank_icon_yz"];
            
            break;
            
        default:
            backView2.image = [UIImage imageNamed:@"icon_other_bank"];
            bankImage.image = [UIImage imageNamed:@"bank_icon_gs"];
            
            break;
    }
    UILabel *titleStr = [[UILabel alloc] init];
    titleStr.frame = CGRectMake( bankImage.frame.size.width+bankImage.frame.origin.x+20,20, backView2.width-20, 20);
    titleStr.text =  [NSString stringWithFormat:@"%@",self.bankName];
    titleStr.textAlignment = NSTextAlignmentLeft;
    titleStr.textColor = [UIColor blackColor];
    titleStr.font = [UIFont systemFontOfSize:15];
    [backView2 addSubview:titleStr];
    
    UILabel *benqizhangdan = [[UILabel alloc] init];
    benqizhangdan.frame = CGRectMake(20, CGRectGetMaxY(titleStr.frame) + 10, titleStr.width-10, 10);
    benqizhangdan.textAlignment = NSTextAlignmentLeft;
    benqizhangdan.textColor = [UIColor grayColor];
    benqizhangdan.font = [UIFont systemFontOfSize:SmallFont];
    [backView2 addSubview:benqizhangdan];
    
    UILabel * balancelabel = [[UILabel alloc] init];
    balancelabel.frame = CGRectMake(20,benqizhangdan.frame.size.height+benqizhangdan.frame.origin.y+10 , 100  * px, 70 * px);
    balancelabel.text = self.strDay;
    balancelabel.textColor = wycMain;
    balancelabel.textAlignment = NSTextAlignmentLeft;
    balancelabel.font = [UIFont systemFontOfSize:25];
    [backView2 addSubview:balancelabel];

    UILabel * balancelabel1 = [[UILabel alloc] init];
    balancelabel1.frame = CGRectMake(70,benqizhangdan.frame.size.height+benqizhangdan.frame.origin.y+15 , 400  * px, 70 * px);
    
    balancelabel1.text = self.strBank;
    balancelabel1.textColor = wycMain;
    balancelabel1.textAlignment = NSTextAlignmentCenter;
    balancelabel1.font = [UIFont systemFontOfSize:15];
    [backView2 addSubview:balancelabel1];
    //还款状态
    self.typelabel = [[UILabel alloc] init];
    self.typelabel.frame = CGRectMake(ScreenWidth-150, 20, 100, 20);
    self.typelabel.textColor = [UIColor whiteColor];
    self.typelabel.layer.masksToBounds = YES;
    self.typelabel.textAlignment = NSTextAlignmentCenter;
    self.typelabel.layer.cornerRadius = 10;
    self.typelabel.font = [UIFont systemFontOfSize:SmallFont];
    [backView2 addSubview:self.typelabel];
    
    if ([self.bankType isEqualToString:@"0"]){
        
        self.typelabel.text = @"待创建计划";
        self.typelabel.backgroundColor = [UIColor blueColor];

    } else if ([self.bankType isEqualToString:@"1"]){
        NSString * aooroveStr = [NSString stringWithFormat:@"待还款"];
        self.typelabel.text = aooroveStr;
        self.typelabel.backgroundColor = [UIColor redColor];
    }else if ([self.bankType isEqualToString:@"2"]){
        NSString * aooroveStr = [NSString stringWithFormat:@"已还清"];
        self.typelabel.text = aooroveStr;
        self.typelabel.backgroundColor = [UIColor greenColor];
    }else if ([self.bankType isEqualToString:@"3"]){
        NSString * aooroveStr = [NSString stringWithFormat:@"智能还款中"];
        self.typelabel.text = aooroveStr;
        self.typelabel.backgroundColor = [UIColor blueColor];
    }else{
        NSString * aooroveStr = [NSString stringWithFormat:@"智能还款中止"];
        self.typelabel.text = aooroveStr;
        self.typelabel.backgroundColor = [UIColor redColor];
        
    }


    //账单日
    UILabel *Statementlabel = [[UILabel alloc] init];
    Statementlabel.frame = CGRectMake(0, balancelabel.frame.size.height+balancelabel.frame.origin.y+10, backView2.width / 4, 50 * px);
    Statementlabel.text = @"账单日";
    Statementlabel.textAlignment = NSTextAlignmentCenter;
    Statementlabel.textColor = [UIColor grayColor];
    Statementlabel.font = [UIFont systemFontOfSize:SmallFont];
    [backView2 addSubview:Statementlabel];


    UILabel *Statement = [[UILabel alloc] init];
    Statement.frame = CGRectMake(Statementlabel.x, CGRectGetMaxY(Statementlabel.frame) , Statementlabel.width, Statementlabel.height);
    Statement.text = [NSString stringWithFormat:@"%@",self.billDate];
    Statement.textAlignment = NSTextAlignmentCenter;
    Statement.textColor = [UIColor blackColor];
    Statement.font = [UIFont systemFontOfSize:SmallFont];
    [backView2 addSubview:Statement];

    //还款日
    UILabel *Repaymentlabel = [[UILabel alloc] init];
    Repaymentlabel.frame = CGRectMake(backView2.width / 4, Statementlabel.y, Statementlabel.width, Statementlabel.height);
    Repaymentlabel.text = @"还款日";
    Repaymentlabel.textAlignment = NSTextAlignmentCenter;
    Repaymentlabel.textColor = [UIColor grayColor];
    Repaymentlabel.font = [UIFont systemFontOfSize:SmallFont];
    [backView2 addSubview:Repaymentlabel];


    UILabel *Repayment = [[UILabel alloc] init];
    Repayment.frame = CGRectMake(Repaymentlabel.x, CGRectGetMaxY(Repaymentlabel.frame), Statementlabel.width, Statementlabel.height);
    NSString * dueDate = [NSString stringWithFormat:@"%@",self.dueDate];
    Repayment.text = dueDate;
    Repayment.textColor = [UIColor blackColor];
    Repayment.textAlignment = NSTextAlignmentCenter;
    Repayment.font = [UIFont systemFontOfSize:SmallFont];
    [backView2 addSubview:Repayment];


    //免息期
    UILabel *Gracelabel = [[UILabel alloc] init];
    Gracelabel.frame = CGRectMake(backView2.width / 2, Statementlabel.y, Statementlabel.width, Statementlabel.height);
    Gracelabel.text = @"免息期";
    Gracelabel.textAlignment = NSTextAlignmentCenter;
    Gracelabel.textColor = [UIColor grayColor];
    Gracelabel.font = [UIFont systemFontOfSize:SmallFont];
    [backView2 addSubview:Gracelabel];
    
    
    UILabel *Grace = [[UILabel alloc] init];
    Grace.frame = CGRectMake(Gracelabel.x, CGRectGetMaxY(Gracelabel.frame) , Statementlabel.width, Statementlabel.height);
    NSString * gracePeriod = [NSString stringWithFormat:@"%@",self.gracePeriod];
    Grace.text = gracePeriod;
    Grace.textColor = [UIColor blackColor];
    Grace.textAlignment = NSTextAlignmentCenter;
    Grace.font = [UIFont systemFontOfSize:SmallFont];
    [backView2 addSubview:Grace];



    //总额度
    UILabel *Totallabel = [[UILabel alloc] init];
    Totallabel.frame = CGRectMake(backView2.width / 4 * 3, Statementlabel.y, Statementlabel.width, Statementlabel.height);
    Totallabel.text = @"总额度";
    Totallabel.textAlignment = NSTextAlignmentCenter;
    Totallabel.textColor = [UIColor grayColor];
    Totallabel.font = [UIFont systemFontOfSize:SmallFont];
    [backView2 addSubview:Totallabel];


    UILabel *Total = [[UILabel alloc] init];
    Total.frame = CGRectMake(Totallabel.x, CGRectGetMaxY(Totallabel.frame), Statementlabel.width, Statementlabel.height);
    Total.textAlignment = NSTextAlignmentCenter;
    NSString * creditLine = [NSString stringWithFormat:@"%.1f",[self.creditLine doubleValue]];
    Total.text = creditLine;
    Total.textColor = [UIColor blackColor];
    Total.font = [UIFont systemFontOfSize:SmallFont];
    [backView2 addSubview:Total];

//        [self setupbottomView];


  
    UIView *titlesView = [[UIView alloc] init];
    titlesView.backgroundColor = [UIColor whiteColor];
    titlesView.frame = CGRectMake(10, backView.frame.size.height +backView.frame.origin.y, ScreenWidth-20, 50);
    titlesView.alpha= 1;//设置阴影的透明度
    [self.view addSubview:titlesView];
    self.titlesView = titlesView;
    
    NSArray * titlearray = @[@"账单明细",@"还款记录",@"消费计划"];
    CGFloat width = (ScreenWidth -20)/ 3;
    CGFloat height = 40;
    
    for (NSInteger i = 0; i < titlearray.count; i++) {
        UIButton *button = [[UIButton alloc] init];
        button.tag = i;
        button.height = height;
        button.width = width;
        button.x = (ScreenWidth -20)/ 3 * i;
        button.y = 15;
        [button setTitle:titlearray[i] forState:UIControlStateNormal];
        [button layoutIfNeeded];//强制布局
        button.titleLabel.textAlignment = NSTextAlignmentCenter;
        [button setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        [button setTitleColor:[UIColor whiteColor] forState:UIControlStateDisabled];
        [button setBackgroundImage:[UIImage imageNamed:@"nomal"] forState:UIControlStateNormal];
        [button setBackgroundImage:[UIImage imageNamed:@"slec"] forState:UIControlStateDisabled];

        button.titleLabel.font = [UIFont systemFontOfSize:48*px];
        [button addTarget:self action:@selector(titleClick:) forControlEvents:UIControlEventTouchUpInside];
        [titlesView addSubview:button];
        
        if (i == 0) {
            [self titleClick:button];
            button.enabled = NO;
            self.selectedButton = button;
            // 让按钮内部的label根据文字内容来计算尺寸
            self.indicatorView.width = 108*px;
            self.indicatorView.centerX = button.centerX ;
        }
    }
    
    
}
- (void)titleClick:(UIButton *)button
{
    //修改按钮状态
    self.selectedButton.enabled = YES;
    button.enabled = NO;
    self.selectedButton = button;
    // 动画
    [UIView animateWithDuration:0.25 animations:^{
        self.indicatorView.width = 108*px;
        self.indicatorView.centerX = button.centerX;
    }];
    //滚动
    CGPoint offset = self.contenView.contentOffset;
    offset.x = button.tag * self.contenView.width;
    [self.contenView setContentOffset:offset animated:YES];
}
#pragma mark - <UIScrollViewDelegate>
- (void)scrollViewDidEndScrollingAnimation:(UIScrollView *)scrollView
{
    //当前的索引
    //长度NSInteger * interger;
    int index = scrollView.contentOffset.x / scrollView.width;
    
    //取出子控制器
    UITableViewController * vc = self.childViewControllers[index];
    vc.tableView.x = scrollView.contentOffset.x;
    vc.tableView.y = 300;
    vc.tableView.width = ScreenWidth;
    vc.tableView.height = scrollView.height - 750 * px;//tableview的底部
    [scrollView addSubview:vc.view];
}

- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
{
    //点击按钮
    int index = scrollView.contentOffset.x / scrollView.width;
    [self titleClick:self.titlesView.subviews[index]];
    
    
    // 添加子控制器的view
    [self scrollViewDidEndScrollingAnimation:scrollView];
}
- (void)setupNav {
    [self.navigationController.navigationBar setBarTintColor:[UIColor whiteColor]];
    [self.navigationController.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor whiteColor]}];
   NSString * titleStr = [NSString stringWithFormat:@"%@(%@)",self.bankName,self.lastNumber];
    self.navigationItem.title = titleStr;
    
    //右侧按钮
    self.navigationItem.rightBarButtonItem = [UIBarButtonItem itemWithImage:@"Three" hight:@"Three" target:self action:@selector(ThreeClick:)];
}

- (void)ThreeClick:(UIButton *)optionButton{
    
    UIWindow *window = [[UIApplication sharedApplication].delegate window];
    CGRect frame = [optionButton convertRect:optionButton.bounds toView:window];
    
    
    OYRPopOption *s = [[OYRPopOption alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth, ScreenHeight)];
    
    s.option_optionContents = @[@"隐藏该卡", @"手动账单"];
    // 使用链式语法直接展示 无需再写 [s option_show];
    [[s option_setupPopOption:^(NSInteger index, NSString *content) {
        
       
        if (index == 0) {
            
            NSMutableDictionary * params = [NSMutableDictionary dictionary];
            params[@"token"] = [WYCAccountTool unarchivetoken];
            params[@"cardId"] = self.cardId;
            params[@"isHideCard"] = @"1";
            [HttpTool POST:creditcardsetHideCard params:params success:^(NSURLSessionDataTask *task, id responseObject) {
                
                if ([[responseObject objectForKey:@"code"] intValue] == 0) {
                
                    [SVProgressHUD showImage:[UIImage imageNamed:@""] status:@"成功"];
                    [SVProgressHUD setDefaultStyle:SVProgressHUDStyleCustom];
                    [SVProgressHUD setForegroundColor:[UIColor whiteColor]]; //字体颜色
                    [SVProgressHUD setBackgroundColor:[UIColor blackColor]];   //背景颜色
                    
                    for (UIViewController *controller in self.navigationController.viewControllers) {
                        if ([controller isKindOfClass:[WYCBillController class]]) {
                            [self.navigationController popToViewController:controller animated:YES];
                            break;
                        }
                    }
                    WYCBillController *SendDrugVC = [[WYCBillController alloc]init];
                    [self.navigationController popToViewController:SendDrugVC animated:YES];
                
                }else{
                
                    [SVProgressHUD showImage:[UIImage imageNamed:@""] status:msgStr];
                    [SVProgressHUD setDefaultStyle:SVProgressHUDStyleCustom];
                    [SVProgressHUD setForegroundColor:[UIColor whiteColor]]; //字体颜色
                    [SVProgressHUD setBackgroundColor:[UIColor blackColor]];   //背景颜色
                }
                
            } fail:^(NSURLSessionDataTask *task, NSError *error) {
                
                [SVProgressHUD showImage:[UIImage imageNamed:@""] status:Failed];
                [SVProgressHUD setDefaultStyle:SVProgressHUDStyleCustom];
                [SVProgressHUD setForegroundColor:[UIColor whiteColor]]; //字体颜色
                [SVProgressHUD setBackgroundColor:[UIColor blackColor]];   //背景颜色
            }];
            
        }else{
            
            WYCHandBillController * OperationBll = [[WYCHandBillController alloc] init];
            [self.navigationController pushViewController:OperationBll animated:NO];
        
        }
        
    } whichFrame:frame animate:YES] option_show];
    
}
#pragma make ---------->>已还清金额
- (void)payofflabelClick{
    WYCIntelligentMoneyController * repay = [[WYCIntelligentMoneyController alloc] init];
        repay.cardId = self.cardId;
    
        //银行卡姓名
        repay.bankName = self.bankName;
    
        //银行卡后四位
        repay.lastNumber = self.lastNumber;
    
        //银行卡多少天出账单
        repay.outbBllDay = self.outbBllDay;
    
        //本期账单金额
        repay.billAmount = self.billAmount;
    
    
        //免息期
        repay.gracePeriod = self.gracePeriod;
    
        repay.bankState = self.bankType;
        //总额度
        repay.creditLine = self.creditLine;
    
    
        //还款日
        repay.dueDate = self.dueDate;
    
    
        //账单日
        repay.billDate = self.billDate;
    repay.bankid = self.bankid;
    
    
    [self.navigationController pushViewController:repay animated:NO];
    
}

#pragma make ---------->>标记已还金额
- (void)alreadylabelClick{
    [self showToast:@"努力开发中..."];

//    consumptionViewController * Fastcon = [[consumptionViewController alloc] init];
//    [self.navigationController pushViewController:Fastcon animated:NO];
}
- (void)buttonClick:(UIButton *)sender{
    
    if (sender.tag == 11) {
        
        self.texField.text = [NSString stringWithFormat:@""];
    
    }else{
        
        self.texField.text = [NSString stringWithFormat:@"%@%@",self.texField.text,sender.titleLabel.text];
        
    }
    
}
#pragma make ----------->>取消
- (void)DetermineClick{
    self.coverView.hidden = YES;
    self.backView.hidden = YES;
    
    NSMutableDictionary * params = [NSMutableDictionary dictionary];
    params[@"token"] = [WYCAccountTool unarchivetoken];
    params[@"cardId"] = self.cardId;
    params[@"payOff"] = @"2";
    params[@"amount"] = self.texField.text;
    [HttpTool POST:creditcardalreadyRepaid params:params success:^(NSURLSessionDataTask *task, id responseObject) {
        if ([[responseObject objectForKey:@"code"] intValue] == 0) {
            
            [SVProgressHUD showImage:[UIImage imageNamed:@""] status:@"标记成功"];
            [SVProgressHUD setDefaultStyle:SVProgressHUDStyleCustom];
            [SVProgressHUD setForegroundColor:[UIColor whiteColor]]; //字体颜色
            [SVProgressHUD setBackgroundColor:[UIColor blackColor]];   //背景颜色
            
        }else{
            
            [SVProgressHUD showImage:[UIImage imageNamed:@""] status:msgStr];
        }
    } fail:^(NSURLSessionDataTask *task, NSError *error) {
        
    }];
}

#pragma make ----------->>取消
- (void)cancelClick{
    
    self.coverView.hidden = YES;
    self.backView.hidden = YES;
}

- (void)viewWillAppear:(BOOL)animated {
    
    [super viewWillAppear:animated];
    [self setupNav];
    //请求
    [self setupRequster];
    //初始化子控制器
    [self setupChildVces];
    //底部的scrollview
    [self setupScrollView];
    [self setupVersion];
    [self.navigationController.navigationBar setBarTintColor:wycMain];
}

- (void)viewWillDisappear:(BOOL)animated {
    
    [super viewWillDisappear:animated];
    
    [self.navigationController.navigationBar setBarTintColor:wycMain];
}
-(void)loadversion
{
    NSDictionary *infoDic = [[NSBundle mainBundle] infoDictionary];
    
    NSMutableDictionary * params = [NSMutableDictionary dictionary];
    NSString *appVersion = [infoDic objectForKey:@"CFBundleShortVersionString"];
    NSLog(@"=======%@",appVersion);
    params[@"version"] = appVersion;
    
    [HttpTool POST:function params:params success:^(NSURLSessionDataTask *task, id responseObject) {
        if ([[responseObject objectForKey:@"code"] intValue ] == 0) {
            NSLog(@"%@",responseObject);
            
            if ([[responseObject objectForKey:@"result"] intValue ] == 0) {
                NSLog(@"隐藏");
                
            }
            else
            {
                NSLog(@"放开");
                [self setupbottomView];
            }
        }
        
        
    } fail:^(NSURLSessionDataTask *task, NSError *error) {
        
    }];
}
@end
